<template>
<div class="add-Man">
	<a-modal
      title="添加外部联系人"
      :visible="visible"
      @cancel="handleCancel"
      width="750px"
      :footer="null">
          <a-form  :form="form" @submit="handleSubmit">
            <a-row>
                 <a-col :span='12' class='ela-220'>
                    <a-form-item label="人员姓名" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
                      <a-input v-decorator="['realName',{rules: [{ required: true, message: '人员姓名不能为空' }]}]" placeholder='请填写联系人姓名'/>
                   </a-form-item>
                 </a-col>
          
                <a-col :span='12' class='ela-220'>
                    <a-form-item label="联系方式：" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
                      <a-input v-decorator="['linkMobile',{rules: [{ required: true, message: '联系方式格式不正确' }]}]" placeholder='请填写联系方式' />
                   </a-form-item> 
                </a-col>
            </a-row>
            <a-row>
<!--                          <a-col :span='12' class='ela-220'>
                    <a-form-item label="名称：" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
                      <a-input v-decorator="['note',{rules: [{ required: true, message: 'Please input your note!' }]}]" placeholder='外部联系人(默认)'/>
                   </a-form-item>
                 </a-col> -->
                <a-col :span='12' class='ela-220'>
                    <a-form-item label="邮箱:" :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
                      <a-input v-decorator="['linkMail',{rules: [{ required: true, message: '邮箱格式不正确' }]}]" placeholder='请填写邮箱'/>
                   </a-form-item>
                </a-col>
            </a-row>
            <a-row class='ant-lable-button'>
              <a-button class='ant-btn-green' html-type="submit">确定</a-button>
              <a-button class='ant-btn-grey' @click="handleCancel">取消</a-button>
            </a-row>
         </a-form>
    </a-modal>
</div>
</template>
<script>
	export default {
	  data() {
	    return {
	        visible: false,
	        form: this.$form.createForm(this),
	        loading: false,
	        addressBookId:'',
	        linkId:'',
	    }
	  },
	  created() {
	  },
	  methods: {
      // 展示模态框
	    showModal(data) {
	      	this.visible = true;
	      	this.addressBookId = data.addressBookId
	      	this.linkId = data.linkId
		        setTimeout(() => {
		          this.form.setFieldsValue({
		            realName:data.realName,
		            linkMobile:data.linkMobile,
		            linkMail:data.linkMail
		          })
		        }, 100);
	    },
      // 取消按钮
      handleCancel(e) {
      	this.$emit('close',true);
        this.visible = false
        this.form.resetFields();
      },
      // 编辑修改数据
         handleSubmit(e) {
         	e.preventDefault();
			this.form.validateFieldsAndScroll((err, values) => {
				if(!err) {
					values.addressBookId = this.addressBookId
					values.linkId = this.linkId
					this.$put('/info/addressBook',values,true).then((r)=>{
					  if(r.status == 200) {
					     this.$message.success(r.data.message);
					     this.handleCancel();
					     this.loading = false;
					  }
					}).catch((e) => {
					    this.loading = false;
					})
				}
			});
         },
	  }
}
</script>
<style lang="less">

</style>